//
//  JZRJSeachBar.m
//  JZRJAPPT
//
//  Created by mac on 16/5/10.
//  Copyright © 2016年 mac. All rights reserved.
//

#import "JZRJSeachBar.h"
#import "UIView+Frame.h"

@implementation JZRJSeachBar
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        // 设置背景
        //self.background = [UIImage imageNamed:@"searchbar_textfield_background"];
        self.backgroundColor = [UIColor whiteColor];
        self.layer.cornerRadius = 5;
        self.enabled = NO;
        self.placeholder = @"请输入您的股票进行量化炒股";
        self.textAlignment = NSTextAlignmentLeft;
        // 设置内容 -- 垂直居中
        self.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
        
        // 设置左边显示一个放大镜
        UIImageView *leftView = [[UIImageView alloc] init];
        leftView.image = [UIImage imageNamed:@"search"];
        leftView.width = leftView.image.size.width + 50;
        leftView.height = leftView.image.size.height + 5;
        // 设置leftView的内容居中
        leftView.contentMode = UIViewContentModeCenter;
        self.leftView = leftView;
        
        // 设置左边的view永远显示
        self.leftViewMode = UITextFieldViewModeAlways;
        
        // 设置右边永远显示清除按钮
        self.clearButtonMode = UITextFieldViewModeAlways;
    }
    return self;
   
}
+ (instancetype)searchBar
{
    return [[self alloc] init];
}
@end
